﻿#region License
// Copyright (c) 2012, David Bennett. All rights reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3.0 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301  USA
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FroggyPlugin.Data;

namespace FroggyPlugin.Devices
{
    /// <summary>
    /// Basic on/off devices.  Covers devices like switches as well as anything else that has
    /// an on/off state, like motion detectors, low battery alarms and anything else.
    /// </summary>
    public class OnOffDevice : BasicDevice
    {
        enum StateIndexes
        {
            On
        }

        /// <summary>
        /// Create a new on/off device.
        /// </summary>
        public OnOffDevice()
        {
            SetState(StateIndexes.On.ToString(), new DeviceState<bool>(DeviceStateBase.DeviceStateType.Boolean, "State", "Basic"));
        }

        /// <summary>
        /// The on state of the device.
        /// </summary>
        public bool On
        {
            get
            {
                DeviceState<bool> state = (DeviceState<bool>)GetState(StateIndexes.On.ToString());
                return state.Value;
            }
            set
            {
                DeviceState<bool> state = (DeviceState<bool>)GetState(StateIndexes.On.ToString());
                state.Value = value;
            }         
        }
    }
}
